import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 待复检信息 */
export interface RecheckTobe {
  id: number // 主键
  accountId?: number // 模具台账id
  drawingNoId?: number // 图号id
  recheckId: number // 复检类型id
  lastRecheckTime: string | Dayjs // 上次复检日期
  ifTmp: number // 是否临时复检
  status: number // 任务状态
  taskId: number // 任务id
  itemId: number // 复检项目主键
  remindF?: number // 提醒标志位
}

// 待复检 API
export const RecheckTobeApi = {
  // 查询待复检分页
  getRecheckTobePage: async (params: any) => {
    return await request.get({ url: `/mold/recheck-tobe/page`, params })
  },

  // 查询待复检详情
  getRecheckTobe: async (id: number) => {
    return await request.get({ url: `/mold/recheck-tobe/get?id=` + id })
  },

  // 新增待复检
  createRecheckTobe: async (data: RecheckTobe) => {
    return await request.post({ url: `/mold/recheck-tobe/create`, data })
  },

  // 修改待复检
  updateRecheckTobe: async (data: RecheckTobe) => {
    return await request.put({ url: `/mold/recheck-tobe/update`, data })
  },

  // 删除待复检
  deleteRecheckTobe: async (id: number) => {
    return await request.delete({ url: `/mold/recheck-tobe/delete?id=` + id })
  },

  /** 批量删除待复检 */
  deleteRecheckTobeList: async (ids: number[]) => {
    return await request.delete({ url: `/mold/recheck-tobe/delete-list?ids=${ids.join(',')}` })
  },

  // 导出待复检 Excel
  exportRecheckTobe: async (params) => {
    return await request.download({ url: `/mold/recheck-tobe/export-excel`, params })
  },

  // 撤销接口
  cancelDispatchRecheckTobe: async (id: number) => {
    return await request.put({ url: `/mold/recheck-tobe/cancel-dispatch?id=${id}` })
  },

  // 审核接口
  auditRecheckTobe: async (data: any) => {
    return await request.put({
      url: `/mold/recheck-tobe/audit`,
      data
    })
  }
}
